package com.example.ibeacon_station;

import java.util.Date;

public class Beacon {
    // Basic info
    private int mId;
    private String mTitle;
    private String mMacAddress;
    private String mUuid;
    private int mMajor;
    private int mMinor;
    private int mTxPower;
    private Double RSSI;
    private Date mTimeStamp;


    public Beacon(String title, String mac){
        mTitle = title;
        mMacAddress = mac;
        // mStepCounter = MainActivity.sStepNav.new StepCounter();
        // mStepCounter.start();
        mTimeStamp = new Date();
    }

    public void updateRSSI(double rssi){
        RSSI = rssi;
        mTimeStamp = new Date();
    }

    /**
     * 解析信标类型
     */
    public static final int BEACON_TYPE_UNKNOWN = 236;
    public static final int BEACON_TYPE_IBEACON = 844;

    public static int judgeBeaconType(String packet){
        switch(packet.substring(0,10)){
            case "0201061AFF":return BEACON_TYPE_IBEACON;
            default:return BEACON_TYPE_UNKNOWN;
        }
    }

    public int getmId() {
        return mId;
    }

    public void setmId(int mId) {
        this.mId = mId;
    }

    public String getmTitle() {
        return mTitle;
    }

    public void setmTitle(String mTitle) {
        this.mTitle = mTitle;
    }

    public String getmMacAddress() {
        return mMacAddress;
    }

    public void setmMacAddress(String mMacAddress) {
        this.mMacAddress = mMacAddress;
    }

    public Double getRSSI() {
        return RSSI;
    }

    public String getmUuid() {
        return mUuid;
    }

    public void setmUuid(String mUuid) {
        this.mUuid = mUuid;
    }

    public int getmMajor() {
        return mMajor;
    }

    public void setmMajor(int mMajor) {
        this.mMajor = mMajor;
    }

    public int getmMinor() {
        return mMinor;
    }

    public void setmMinor(int mMinor) {
        this.mMinor = mMinor;
    }

    public int getmTxPower() {
        return mTxPower;
    }

    public void setmTxPower(int mTxPower) {
        this.mTxPower = mTxPower;
    }

    public Date getmTimeStamp() {
        return mTimeStamp;
    }

    public void setmTimeStamp(Date mTimeStamp) {
        this.mTimeStamp = mTimeStamp;
    }

    @Override
    public String toString() {
        return "Beacon{" +
                "mId=" + mId +
                ", mTitle='" + mTitle + '\'' +
                ", mMacAddress='" + mMacAddress + '\'' +
                ", mUuid='" + mUuid + '\'' +
                ", mMajor=" + mMajor +
                ", mMinor=" + mMinor +
                ", mTxPower=" + mTxPower +
                ", mTimeStamp=" + mTimeStamp +
                '}';
    }
}
